﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using SQLBuilderWPF.View_Models;
using UpdateControls.XAML;
using Microsoft.Win32;
using System.IO;
using System.Xml;
using System.Windows.Media.Animation;
using ICSharpCode.AvalonEdit.Highlighting;

namespace SQLBuilderWPF
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            this.DataContext = new MainWindowViewModel();
            // Load our custom highlighting definition
            IHighlightingDefinition customHighlighting;
            using (Stream s = typeof(MainWindow).Assembly.GetManifestResourceStream("SQLBuilderWPF.MapInfoSQL.xshd"))
            {
                if (s == null)
                    throw new InvalidOperationException("Could not find embedded resource");
                using (XmlReader reader = new XmlTextReader(s))
                {
                    customHighlighting = ICSharpCode.AvalonEdit.Highlighting.Xshd.
                        HighlightingLoader.Load(reader, HighlightingManager.Instance);
                }
            }
            // and register it in the HighlightingManager
            HighlightingManager.Instance.RegisterHighlighting("MapInfoSQLHighlighting", new string[] { ".MISQL" }, customHighlighting);

            this.finalblock.SyntaxHighlighting = customHighlighting;
            this.whereblock.SyntaxHighlighting = customHighlighting;
            this.selectblock.SyntaxHighlighting = customHighlighting;
        }
    }
}
